package com.tianji.learning.controller;


import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.api.dto.leanring.LearningRecordFormDTO;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学习记录表 前端控制器
 * </p>
 *
 * @author Aimer
 * @since 2025-11-06
 */
@RestController
@RequestMapping("/learning-records")
@Api(tags = "学习记录")
@RequiredArgsConstructor
public class LearningRecordController {
    private final ILearningRecordService iLearningRecordService;
    @GetMapping("/course/{courseId}")
    @ApiOperation("查询该课程的学习记录")
    public LearningLessonDTO queryLearningRecordByCourse(@ApiParam(value = "课程id",example = "2") @PathVariable Long courseId){
       return iLearningRecordService.queryLearningRecordByCourse(courseId);
    }

    @ApiOperation("提交学习记录")
    @PostMapping
    public void addLearningRecord(@RequestBody LearningRecordFormDTO learningRecordFormDTO){
        iLearningRecordService.addLearningRecord(learningRecordFormDTO);
    }
}
